package com.carmanage.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.carmanage.dao.ILineDao;
import com.carmanage.domain.Line;

@Component
public class LineDaoImpl implements ILineDao {
	private SessionFactory sessionFactory;

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}


	public void saveLine(Line line) {
		 Session session = sessionFactory.openSession();
		 session.save(line);
		 session.close();
	}


	public List<Line> getAllLine() {
		Session session = sessionFactory.openSession();
		Query query = session.createQuery("from Line");
		List<Line> lines = query.list();
		session.close();
		return lines;
	}
	
	
}
